import {Router,Route,hashHistory,IndexRedirect} from "react-router";
//首页 
import store from "./store/store.js"

import Home from "./view/page/home_ui.js" 
import Fenlei from "./view/page/fenlei_ui.js"
import Ku from "./view/page/kefu.js"
import Goods from "./view/page/goods_ui.js"
import So from "./view/page/sousuo.js"
import SL from "./view/page/list_ui.js" 
import RI from "./view/page/register.js"
import Ni from "./view/conent/footer_pt_register.js"
import VIP from "./view/conent/footer_pt_register_vip.js"
import SI from "./view/page/sign.js"
import ME from "./view/page/isme_ui.js"
import CR from "./view/page/car.js"


 
var Kong = React.createClass({
	
	render :function(){
		return this.props.children
	}
})
export default React.createClass({ 
	 goods:function(){
	 	var shi = location.hash.indexOf("?")+10
		var mo = location.hash.indexOf("&") 
		var goodsid = location.hash.slice(shi,mo) 
		//var goodsid = this.props.params.goodsid; 
		var url =  "http://www.chawo.com/mobile/index.php?act=goods&op=goods_detail&goods_id="+goodsid+"&key=&dis_id="
        		store.dispatch(function(dispatch , state){
    		fetch(url)
                .then(res=>res.json())
                .then(data=>{
                    dispatch({
                        type : "GOODS_QING",
                        content : data
                    })
                })
}) 
	 },
	 componentDidMount:function(){ 
	 },
	render : function(){
		//<Route path="home/goods" component={Goods} onEnter={this.goods}/>
		return (
			<Router history={hashHistory}>
			 	<Route path="/" component={Kong}>
	                <IndexRedirect to="home" />
	                <Route path="home" component={Home} /> 
	                <Route path="home/goods" component={Goods} onEnter={this.goods} />
	                <Route path="home/sousuo" component={So}/>
	                <Route path="home/list/:name" component={SL}/>
	                <Route path="fenlei" component={Fenlei} />
	                <Route path="meizi" component={Ku}  />
	                <Route path="register" component={RI} >
	                	 <IndexRedirect to="ptuser" />
	                	<Route path="ptuser" component={Ni}  />
	                	<Route path="vipuser" component={VIP}  />
	                </Route>
	                <Route path="sign" component={SI}/>
	                <Route path="isme" component={ME}/>
	                <Route path="car" component={CR}/>
           		 </Route>
			 </Router>
		)
	}
})
						




